function getFileExtension(url) {
	return url.split('.').pop().split(/\?/)[0]; // 去掉 URL 查询参数部分
}

function isImage(url) {
	const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
	const extension = getFileExtension(url).toLowerCase();
	return imageExtensions.includes(extension);
}

function isVideo(url) {
	const videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv', 'wmv'];
	const extension = getFileExtension(url).toLowerCase();
	return videoExtensions.includes(extension);
}
// 示例
const url = 'https://example.com/video.mp4';



const getIsImage = (url) => {
	if (isImage(url)) {
		console.log('This is an image.');
		return 1
	} else if (isVideo(url)) {
		console.log('This is a video.');
		return 2
	} else {
		console.log('Unknown file type.');
		return 3
	}
}

const GlobalPlugin = {
  install(Vue) {
    Vue.prototype.$getIsImage = getIsImage
  }
};


export default GlobalPlugin;